package com.emm.yixun.website.controller.common;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.emm.yixun.common.model.enums.PaymentMethodEnum;

/**
 * 文件上传基础类
 * 
 * @author RUING
 * 
 */
@Controller
@RequestMapping("/common/enum/")
public class EnumController {
	private static Logger log = Logger.getLogger(EnumController.class);
	/*"#{configproperties['file.serviceUrl']}"*/

	/**
	 * 上传文件(apk或者UI)
	 * 
	 * @param picture
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/getJsonString")
	public void getJsonString(HttpServletRequest request, HttpServletResponse response, MultipartFile file) throws IOException {
		String className = request.getParameter("className");
		
	}
	
	
	public static void main(String[] args) {
		String classPrefix = "com.emm.yixun.common.model.enums.";
		String className = classPrefix + "PaymentMethodEnum";
		try {
			Class cls = Class.forName(className);
			Object obj[] = cls.getEnumConstants();
			JSONArray pmArray = new JSONArray();
			for (Object val : obj) {
				Enum e = (Enum)val;
				System.out.println(e.ordinal());
				System.out.println(e.name());
				
//				JSONObject row = new JSONObject();
//				row.put("value", val.getClass().getMethod("getNo", null));
//				row.put("name", val.getClass().getMethod("getDes", null));
//				pmArray.add(row);
			}
			System.out.println(pmArray.toJSONString());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
